package demo4;

import org.omg.CORBA.PUBLIC_MEMBER;

abstract class Animal{
    public String name;
    public int age;
    public Animal(String name,int age) {
        this.age = age;
        this.name = name;
    }
    public abstract void Eat();

}

interface    IFly {
    void fly();
}
interface IRun {
    void run();
}

interface ISwim {
    void swim();
}
class Robot implements IRun {
    @Override
    public void run() {
        System.out.println("机器人在奔跑");
    }
}
class Dog extends Animal implements IRun {
    public Dog(String name,int age) {
        super(name,age);


    }
    @Override
    public void run() {
        System.out.println(this.name+"正在跑");
    }
    public  void Eat() {
        System.out.println(this.name+"正在吃狗粮");
    }

}
class Frog extends Animal implements IRun,ISwim {
    public Frog(String name,int age){
        super(name,age);
    }
    @Override
    public void run() {
        System.out.println(this.name+"正用两条腿跳着跑");
    }

    @Override
    public void swim() {
        System.out.println(this.name+"正在水里游");
    }

    @Override
    public void Eat() {
        System.out.println(this.name+"正在吃蚊子");
    }
}
class Duck extends Animal implements IRun,ISwim,IFly {
    public Duck(String name,int age) {
        super(name,age);
    }

    @Override
    public void run() {
        System.out.println(this.name+"正在跑");
    }

    @Override
    public void swim() {
        System.out.println(this.name+"正在水里游");

    }

    @Override
    public void fly() {
        System.out.println(this.name+"正在水里努力扇动翅膀");
    }

    @Override
    public void Eat() {
        System.out.println(this.name+"正在吃小鱼");
    }
}

public class Test {
    public static void Func1(Animal animal) {
        animal.Eat();
    }
    public static void running(IRun iRun) {
        iRun.run();
    }
    public static void swimming(ISwim iSwim) {
        iSwim.swim();
    }
    public static void flying(IFly iFly) {
        iFly.fly();
    }

    public static void main(String[] args) {
        running(new Dog("打狗狗",1));
        running(new Frog("丑青蛙",1));
        running(new Duck("唐老鸭",1));
        System.out.println("=================");
        flying(new Duck("唐老鸭",1));
        System.out.println("=================");
        swimming(new Frog("丑青蛙",1));
        swimming(new Duck("唐老鸭",1));
        System.out.println("===================");
        running(new Robot());
    }
    public static void main2(String[] args) {
        Func1(new Dog("打狗狗",1));
        Func1(new Frog("丑青蛙",1));
        Func1(new Duck("唐老鸭",1));
    }
    public static void main1(String[] args) {
        Animal animal1 = new Duck("唐老鸭",2);
        animal1.Eat();
    }
}
